import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/layout/index.vue'
const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: '',
        name: 'home',
        component: () => import('@/views/home/index.vue')
      },
      {
        path: 'goods/:id',
        name: 'goods',
        component: () => import('@/views/goods/index.vue')
      },
      {
        path: '/cart',
        name: 'cart',
        component: () => import('@/views/cart/index.vue')
      },
      {
        path: '/order',
        name: 'order',
        component: () => import('@/views/order/index.vue')
      },
      {
        path: '/pay',
        name: 'pay',
        component: () => import('@/views/pay/index.vue')
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/index.vue')
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes,
  scrollBehavior() {
    // vue2 return {x: 0, y: 0}
    return { left: 0, top: 0 }
  }
})

export default router
